package com.kaigejava.rulesengine.engine.core.utils;

import com.alibaba.fastjson.JSONObject;
import com.kaigejava.rulesengine.engine.core.api.RulesChangeType;
import com.kaigejava.rulesengine.engine.dto.CreRuleDto;


/**
 * @author kaigejava
 */
public class ProducerMessageBuilder {

    public static final String RULE = "rule";
    public static final String TYPE = "type";

    /**
     * build producer message
     * @param creTaskRuleDto
     * @param rulesChangeType
     * @return
     */
    public static String buildMessage(CreRuleDto creTaskRuleDto, RulesChangeType rulesChangeType) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(RULE,creTaskRuleDto);
        jsonObject.put(TYPE,rulesChangeType.getType());
        return jsonObject.toJSONString();
    }
}
